package com.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sfzy.entity.Course;
import com.sfzy.mapper.CourseMapper;
import com.sfzy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;
    @Override
    public int addCourse(Course course) {
        return courseMapper.addCourse(course);
    }

    @Override
    public int deleteCourse(int id) {
        return courseMapper.deleteCourse(id);
    }

    @Override
    public int updateCourse(Course course) {
        return courseMapper.updateCourse(course);
    }

    @Override
    public Course getCourseById3(int id) {
        return courseMapper.getCourseById3(id);
    }

    @Override
    public PageInfo<Course> getAllCourseByPage3(Course course, int pageNum, int pageSize) {
        //插件分页
        PageHelper.startPage(pageNum, pageSize);
        //调自己方法
        List<Course> courses = courseMapper.getAllCourseByPage3(course);
        //封装
        PageInfo<Course> pageInfo = new PageInfo<>(courses);

        return pageInfo;
    }


}
